import 'package:flutter/material.dart';

class AppBarDemoPage extends StatelessWidget {
  const AppBarDemoPage({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return DefaultTabController(
        length: 2,
        child: Scaffold(
          appBar: AppBar(
            backgroundColor: Colors.purple,
            title: Text('AppBarDemoPage'),
            //如果是二级页面返回图标`<-`会被覆盖
            // leading: IconButton(
            //   icon: Icon(Icons.menu),
            //   onPressed: () {},
            // ),
            //右上角图标
            actions: [
              IconButton(
                icon: Icon(Icons.search),
                onPressed: () {},
              ),
              IconButton(
                icon: Icon(Icons.settings),
                onPressed: () {},
              )
            ],
            bottom: TabBar(
              isScrollable: true,
              tabs: [
                Tab(
                  text: "热门",
                ),
                Tab(
                  text: "推荐",
                )
              ],
            ),
          ),
          //数量要与上面TabBar.tabs一致
          body: TabBarView(
            children: [
              ListView(
                children: [
                  ListTile(
                    title: Text("a"),
                  ),
                  ListTile(
                    title: Text("b"),
                  )
                ],
              ),
              ListView(
                children: [
                  ListTile(
                    title: Text("c"),
                  ),
                  ListTile(
                    title: Text("d"),
                  )
                ],
              )
            ],
          ),
        ));
  }
}
